﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Classwork06
{
    public partial class Form1 : Form
    {
        private string path1 = null;
        private string path2 = null;

        public Form1()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            string path = @"..\..\Data\TextFile1.txt";
            if (path1 == null)
                path1 = path;
            else if(path2 == null)
                path2 = path;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string path = @"..\..\Data\TextFile2.txt";
            if (path1 == null)
                path1 = path;
            else if(path2 == null)
                path2 = path;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string path = @"..\..\Data\TextFile3.txt";
            if (path1 == null)
                path1 = path;
            else if (path2 == null)
                path2 = path;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            App a = new App();
            try
            {
                if (path1 == null || path2 == null)
                    throw new ArgumentNullException();
                a.readAndWrite(path1, path2);
                label2.Text = "生成成功！";
            }
            catch(ArgumentNullException)
            {
                label2.Text = "未选择两个文件！";
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            path1 = null;
            path2 = null;
            label2.Text = "已清空选择！";
        }

        private void button6_Click(object sender, EventArgs e)
        {
            App a = new App();
            a.deleteText();
            label2.Text = "文件已删除！";
        }
    }
}
